<!DOCTYPE HTML>
<html> 
	<head>
	    <title>
       		5 in 1
        </title>
	
		<!--Index-->
		<script src="js/indexjs/scene_intro.js"></script>
		<script src="js/indexjs/scene_credit.js"></script>
		<script src="js/indexjs/button.js"></script>
		
		<!--pong-->
		<script src="js/game_1/game_1_background.js"></script>
		<script src="js/game_1/game_1_ball.js"></script>
		<script src="js/game_1/game_1_pallete.js"></script>
		<script src="js/game_1/game_1_Inimigo.js"></script>
		<script src="js/game_1/game_1_block.js"></script>
		<script src="js/game_1/game_1_button.js"></script>
		<script src="js/game_1/game_1_scene_game_over.js"></script>
		<script src="js/game_1/game_1_scene_intro.js"></script>
		<script src="js/game_1/level/game_1_scene_level_1.js"></script>
		<script src="js/game_1/level/game_1_scene_level_2.js"></script>
		<script src="js/game_1/level/game_1_scene_level_3.js"></script>
		<script src="js/game_1/game_1_scene_the_end.js"></script>
		<script src="js/game_1/game_1.js"></script>

		<!--arkanoid-->
		<script src="js/game_2/game_2_background.js"></script>
		<script src="js/game_2/game_2_ball.js"></script>
		<script src="js/game_2/game_2_bloco.js"></script>
		<script src="js/game_2/game_2_botao.js"></script>
		<script src="js/game_2/game_2_paleta.js"></script>
		<script src="js/game_2/game_2_sceneganhou.js"></script>
		<script src="js/game_2/game_2_sceneinstrucoes.js"></script>
		<script src="js/game_2/game_2_scenelevel1.js"></script>
		<script src="js/game_2/game_2_scenelevel2.js"></script>
		<script src="js/game_2/game_2_scenemenu.js"></script>
		<script src="js/game_2/game_2_sceneperdeu.js"></script>
		<script src="js/game_2/game_2.js"></script>
		
		<!--invaders-->
		<script src="js/game_3/game_3_background.js"></script>
		<script src="js/game_3/game_3_pallete.js"></script>
		<script src="js/game_3/game_3_scene_intro.js"></script>
		<script src="js/game_3/game_3_scene_level_1.js"></script>
		<script src="js/game_3/game_3_scene_the_end.js"></script>
		<script src="js/game_3/game_3_scene_game_over.js"></script>
		<script src="js/game_3/game_3.js"></script>
		<script src="js/game_3/game_3_block.js"></script>
		<script src="js/game_3/game_3_tiro.js"></script>
		<script src="js/game_3/game_3_button.js"></script>	

		<!--shooter--> 
		<script src="js/game_4/game_4_sceneintroducao.js"></script>
		<script src="js/game_4/game_4_background.js"></script>
		<script src="js/game_4/game_4_fimganhou.js"></script>
		<script src="js/game_4/game_4_player.js"></script>
		<script src="js/game_4/game_4_inimigo.js"></script>
		<script src="js/game_4/game_4_scenelevel1.js"></script>
		<script src="js/game_4/game_4_fimperdeu.js"></script>
		<script src="js/game_4/game_4_interface.js"></script>
		<script src="js/game_4/game_4_animacao.js"></script>
		<script src="js/game_4/game_4_tiro.js"></script>
		<script src="js/game_4/game_4.js"></script>
		<script src="js/game_4/game_4_button.js"></script>

		<!--quinto jogo-->
		<script src="js/game_5/game_5_background.js"></script>
		<script src="js/game_5/game_5_scene_intro.js"></script>
		<script src="js/game_5/game_5.js"></script>
		<script src="js/game_5/game_5_button.js"></script>
  
  		<!-- UNITY -->
  		
  <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
		<script type="text/javascript">
		<!--
		var unityObjectUrl = "http://webplayer.unity3d.com/download_webplayer-3.x/3.0/uo/UnityObject2.js";
		if (document.location.protocol == 'https:')
			unityObjectUrl = unityObjectUrl.replace("http://", "https://ssl-");
		document.write('<script type="text\/javascript" src="' + unityObjectUrl + '"><\/script>');
		-->
		</script>
		<script type="text/javascript">
		<!--
			var config = {
				width: 800, 
				height: 600,
				params: { enableDebugging:"0" }
				
			};
			var u = new UnityObject2(config);

			jQuery(function() {

				var $missingScreen = jQuery("#unityPlayer").find(".missing");
				var $brokenScreen = jQuery("#unityPlayer").find(".broken");
				$missingScreen.hide();
				$brokenScreen.hide();
				
				u.observeProgress(function (progress) {
					switch(progress.pluginStatus) {
						case "broken":
							$brokenScreen.find("a").click(function (e) {
								e.stopPropagation();
								e.preventDefault();
								u.installPlugin();
								return false;
							});
							$brokenScreen.show();
						break;
						case "missing":
							$missingScreen.find("a").click(function (e) {
								e.stopPropagation();
								e.preventDefault();
								u.installPlugin();
								return false;
							});
							$missingScreen.show();
						break;
						case "installed":
							$missingScreen.remove();
						break;
						case "first":
						break;
					}
				});
				u.initPlugin(jQuery("#unityPlayer")[0], "WebColdDay.unity3d");
			});
		-->
		
			<!-- UNITY -->
			
			var completouJogo1 = true;
			var completouJogo2 = true;
			var completouJogo3 = true;
			var completouJogo4 = false;
						
	<!--nao preciso chamar pois a div ja comeca escondida...-->
	function hideUnity() 
	{
		document.getElementById("unity").style.display = 'none';    
    	document.getElementById("unity").style.visibility = 'hidden';
    	document.getElementById("html5").style.display = 'inline';    
    	document.getElementById("html5").style.visibility = 'visible';
	} 

	<!--chamo esta funcao qd acabar os 4 jogos, ja esconde o canvas...-->
	function showUnity() 
	{
		if(completouJogo1 && completouJogo2 && completouJogo3 && completouJogo4)
		{
			document.getElementById("unity").style.display = 'inline';    
    		document.getElementById("unity").style.visibility = 'visible';
    		document.getElementById("html5").style.display = 'none';    
    		document.getElementById("html5").style.visibility = 'hidden';
		}
	} 
		
		</script>
		
		<!-- UNITY -->
		
		<style type="text/css">
		<!--
		body {
			font-family: Helvetica, Verdana, Arial, sans-serif;
			background-color: white;
			color: black;
			
		}
		a:link, a:visited {
			color: #000;
		}
		a:active, a:hover {
			color: #666;
		}
		p.header {
			font-size: small;
		}
		p.header span {
			font-weight: bold;
		}
		p.footer {
			font-size: x-small;
		}
		div.content {
			/*margin: auto;
			*/
			width: 800px;
		}
		div.broken,
		div.missing {
			margin: auto;
			position: relative;
			top: 50%;
			width: 193px;
		}
		div.broken a,
		div.missing a {
			height: 63px;
			position: relative;
			top: -31px;
		}
		div.broken img,
		div.missing img {
			border-width: 0px;
		}
		div.broken {
			display: none;
		}
		div#unityPlayer {
			cursor: default;
			height: 600px;
			width: 800px;
		}
		-->
		</style>
		
		<!-- UNITY -->
  
   </head>
        
		<body>
		
		<!-- unity game-->
		<div id="unity">
		<div class="content">
			<div id="unityPlayer">
				<div class="missing">
					<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
						<img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
					</a>
				</div>
				<div class="broken">
					<a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now! Restart your browser after install.">
						<img alt="Unity Web Player. Install now! Restart your browser after install." src="http://webplayer.unity3d.com/installation/getunityrestart.png" width="193" height="63" />
					</a>
				</div>
			</div>
		</div>
		</div>
		<script type="text/javascript">document.getElementById("unity").style.visibility = 'hidden'; document.getElementById("unity").style.display = 'none';</script>
				
		<!-- canvas html5 game-->
		<div id = "html5">
		<canvas width="800" height="600" id="main" style="border:1px solid #000000;"></canvas>
		</div>
		
		<!-- like buttom -->
		<br>
		<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.facebook.com/CincoJogosEmUm&;layout=standard&<br>
		2.
		show_faces=false&width=380&action=like&colorscheme=light&height=25&locale=pt_BR" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:250px; height:25px;" allowTransparency="true"></iframe>
		
		<!--
		<br>
		<a name="fb_share” type=”button” share_url=”www.facebook.com/CincoJogosEmUm"��>
		<script src=”http://static.ak.fbcdn.net/connect.php/js/FB.Share” type=”text/javascript”> </script>
		--!>
				
				
		</body>
   
   	<script>
   	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
   	if (!is_chrome)//!?
   	{
   		document.write("<h2><br/>PLEASE USE THE <a href='http://www.google.com/intl/pt-BR/chrome/browser/'>GOOGLE CHROME</a> :) </h2>");
   	}
   	else
   	{
   	 
   	var canvas = document.getElementById("main");
   	var screen = canvas.getContext("2d");
   	
	//Tamanho de tela
   	var tamanho_tela_x = 800;
   	var tamanho_tela_y = 600;
	
	//Pause
    var paused = false;
    
	//Intro INDEX
    var intro = new SceneIntro();
	
	//Credito INDEX
	var credit = new SceneCredit();
	
	//PONG
	var game_1 = new Game_1();
	
	//ARKANOID
	var game_2 = new Game_2();
	
	//INVADERS
	var game_3 = new Game_3();
	
	//SPACE SHOOTER
	var game_4 = new Game_4();
	
	//Quinto jogo
	var game_5 = new Game_5();
	
	var SCENE = { INTRO: 0, CREDITS: 1, GAME_1: 2, GAME_2: 3, GAME_3: 4, GAME_4: 5, GAME_5: 6 }
	
	//COMEÇANDO COM INTRODUÇÃO DO INDEX = MENU PRINCIPAL
	var currentScene = SCENE.INTRO;
	
	load();

	function load()
	{	
		if((true))
		{
			loop();
		}
		else
		{
			setTimeout(load, 30 );
		}
	}

	function loop()
	{
		//Atualizando
		update();
		
		//Desenhando
		draw();
		
		//Loop
		setTimeout(loop, 30 );
	}

	function update()
	{	
		switch(currentScene)
		{
			case SCENE.INTRO:
			{
				intro.update();	
			}
			break;
			case SCENE.CREDIT:
			{
				credit.update();
			}
			break;
			case SCENE.GAME_1:
			{
				game_1.update();
			}
			break;
			case SCENE.GAME_2:
			{
				game_2.update();
			}
			break;
			case SCENE.GAME_3:
			{
				game_3.update();
			}
			break;
			case SCENE.GAME_4:
			{
				game_4.update();
			}
			break;
			case SCENE.GAME_5:
			{
				game_5.update();
			}
			break;
		}
		
	}

	function draw()
	{
		clear();

		switch(currentScene)
		{	
			case SCENE.INTRO:
			{
				intro.draw();	
			}
			break;
			case SCENE.CREDIT:
			{
				credit.draw();
			}
			break;
			case SCENE.GAME_1:
			{
				game_1.draw();
			}
			break;
			case SCENE.GAME_2:
			{
				game_2.draw();
			}
			break;
			case SCENE.GAME_3:
			{
				game_3.draw();
			}
			break;
			case SCENE.GAME_4:
			{
				game_4.draw();
			}
			break;
			case SCENE.GAME_5:
			{
				game_5.draw();
			}
			break;
		}

	}

	function clear()
	{
		screen.clearRect(0,0,tamanho_tela_x,tamanho_tela_y);
	}

	window.addEventListener('keydown', key_down, true);
	window.addEventListener('keyup', key_up, true);
	window.addEventListener('mousemove', mouse_move, true);
	window.addEventListener('mouseup', mouse_up, true);
	window.addEventListener('mousedown', mouse_down, true);

	function key_down(key)
	{
		switch(currentScene)
		{
			case SCENE.INTRO:
			{
				intro.key_down(key);	
			}
			break;
			case SCENE.CREDIT:
			{
				credit.key_down(key);
			}
			break;
			case SCENE.GAME_1:
			{
				game_1.key_down(key);	
			}
			break;
			case SCENE.GAME_2:
			{
				game_2.key_down(key);	
			}
			break;
			case SCENE.GAME_3:
			{
				game_3.key_down(key);	
			}
			break;
			case SCENE.GAME_4:
			{
				game_4.key_down(key);	
			}
			break;
			case SCENE.GAME_5:
			{
				game_5.key_down(key);	
			}
			break;
		}
	}

	function key_up(key)
	{
		switch(currentScene)
		{			
			case SCENE.INTRO:
			{
				intro.key_up(key);
			}
			break;
			case SCENE.CREDIT:
			{
				credit.key_up(key);
			}
			break;
			case SCENE.GAME_1:
			{
				game_1.key_up(key);
			}
			break;
			case SCENE.GAME_2:
			{
				game_2.key_up(key);
			}
			break;
			case SCENE.GAME_3:
			{
				game_3.key_up(key);
			}
			break;
			case SCENE.GAME_4:
			{
				game_4.key_up(key);
			}
			break;
			case SCENE.GAME_5:
			{
				game_5.key_up(key);
			}
			break;
		}
	}
	
	function mouse_move(mouse)
	{
		switch(currentScene)
		{			
			case SCENE.INTRO:
			{
				//intro.mouse_move(mouse);
			}
			break;
			case SCENE.CREDIT:
			{
				//credit.mouse_move(mouse);
			}
			break;
			case SCENE.GAME_1:
			{
				//game_1.mouse_move(mouse);
			}
			break;
			case SCENE.GAME_2:
			{
				//game_2.mouse_move(mouse);
			}
			break;
			case SCENE.GAME_3:
			{
				game_3.mouse_move(mouse);
			}
			break;
			case SCENE.GAME_4:
			{
				//game_4.mouse_move(mouse);
			}
			break;
			case SCENE.GAME_5:
			{
				//game_5.mouse_move(mouse);
			}
			break;
		}
	}

	function mouse_up(mouse)
	{

	}

	function mouse_down(mouse)
	{
		switch(currentScene)
		{
			case SCENE.INTRO:
			{
				intro.mouse_down(mouse);
			}
			break;
			case SCENE.CREDIT:
			{
				credit.mouse_down(mouse);
			}
			break;
			case SCENE.GAME_1:
			{
				game_1.mouse_down(mouse);
			}
			break;
			case SCENE.GAME_2:
			{
				game_2.mouse_down(mouse);
			}
			break;
			case SCENE.GAME_3:
			{
				game_3.mouse_down(mouse);
			}
			break;
			case SCENE.GAME_4:
			{
				game_4.mouse_down(mouse);
			}
			break;
			case SCENE.GAME_5:
			{
				game_5.mouse_down(mouse);
			}
			break;
		}
	}


	function Collide(x1, y1, w1, h1, x2, y2, w2, h2)
	{	
		if((x1+w1<x2)//se rect1 esquerda rect2
		||(x1>x2+w2)//se rect1 direita rect2
		||(y1+h1<y2)//se rect1 acima rect2
		||(y1>y2+h2))//se rect1 abaixo rect2
		{
			return false;//nao colidiu
		}
		else
		{
			return true;//colidiu
		}
	}
	
	}
	</script>
</html>